import Vue from 'vue'
import VueRouter from 'vue-router'
import Storage from '@/assets/js/storage.js'

Vue.use(VueRouter)
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const routes = [
  {
    path: '/',
    name: '',
    component: () => import('../views/child.vue'),
    redirect: '/home',
    children: [
      {
        name: 'home',
        path: '/home',
        component: () => import('../views/home/home.vue')
      }
    ]
  },
  {
    path: '/error',
    component: () => import('../views/500.vue')
  },
  {
    path: '*',
    component: () => import('../views/404.vue')
  }
]

const BASE_URL = '/'

//配置跳转
const router = new VueRouter({
  mode: 'history',
  base: BASE_URL,
  routes
})

export default router
